<script>
    let name = '';
    let password = '';
    let response ='';
    let email = '';
    let phone = '';
    let mark = '';



    let register = (e) => {
      alert("123");
        let userdata = {
            username :"hello",
        }
	fetch(`/api/register`,{
        method:'POST' ,
        headers:{
            'Content-Type':'application/json'
        },
        body:JSON.stringify(userdata)
    })
		.then((v) => {
			v.text().then((t) => {
				response = t;
			});
		})
		.catch((err) => {
			response=err;
		});
    if(response!=''){
      if(response=="注册成功！"){
        alert(response)
        location.href="/login"
      }
      else{
        alert(response)
      }
      
 }
};
  </script>
  
  <style>
    .registration-form {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 300px;
      margin: 0 auto;
    }
  
    .registration-form input {
      margin-bottom: 10px;
      padding: 5px;
      width: 100%;
      border: 1px solid #ccc;
      border-radius: 4px;
      color: black;
    }
  
    .registration-form button {
      padding: 10px 20px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }
  
    .registration-form button:hover {
      background-color: #45a049;
    }
    .welcome-text {
      font-weight: bold; /* 设置字体为粗体 */
  font-size: 24px; /* 设置字体大小 */
  color: #ff0000; /* 设置字体颜色为红色 */
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* 设置文本阴影 */
  align-items: center;
 }
  </style>
  
  <div class="registration-form">
    <h1 class="welcome-text">欢迎来到用户管理系统</h1>
    <form on:submit={register}>
      <input type="text" placeholder="用户名" bind:value={name} >
      <input type="text" placeholder="密码" bind:value={password} >
      <button type="submit">测试</button>
     
      <input type="text" placeholder="邮箱" bind:value={email} >
      <input type="text" placeholder="电话" bind:value={phone} >
      <input type="text" placeholder="备注" bind:value={mark} >
      <button type="submit">注册</button>
    </form>
  </div>